<div class="layui-fluid nepadmin-pad0 nepadmin-mar0 list0"  lay-title="排行榜">
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card layui-tab layui-tab-brief" style="margin: 0;">
                    <ul class="layui-tab-title">
                        <li class="layui-this" value="1" click_num="2">代理排行榜</li>
                        <li value="2" click_num="1">会员排行榜</li>
                        <li value="3" click_num="1">学校排行榜</li>
                        <li value="4" click_num="1">宿舍排行榜</li>
                    </ul>
                    <div class="layui-card-body layui-tab-content hxr-card-body" style="padding: 15px;">
                        <div class="layui-tab-item layui-show" >
                            <div class="layui-form hxradmin-card-header">
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label" style="width: 140px;">时间范围</label>
                                        <div class="layui-input-inline" style="width: 250px;">
                                            <input type="text" name="search_time_agent" id='date-1' class="layui-input" readonly>
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">类型</label>
                                        <div class="layui-input-inline">
                                            <div class="layui-unselect layui-form-select">
                                                <div class="layui-select-title"><input name="type" type="text" placeholder="充值" value="" readonly class="layui-input layui-unselect"><i
                                                        class="layui-edge"></i></div>
                                                <dl class="layui-anim layui-anim-upbit" style="">
                                                    <dd data='1' class="layui-this">充值</dd>
                                                    <dd data='2'>消费</dd>
                                                    <dd data='3'>收益</dd>
                                                    <dd data='4'>佣金</dd>
                                                    <dd data='5'>效益</dd>
                                                </dl>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <button class="layui-btn agentsearch" data-type="reload" >搜索</button>
                                    </div>
                                    <div class="layui-inline">
                                        <button class="layui-btn pexcel" data-type="excel" id="pexcel">导出数据</button>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-card-body">
                                <table class="layui-hide" id="agent-list-table" lay-filter="agent-list-table"></table>
                            </div>
                        </div>
                        <div class="layui-tab-item" id="commissionset">
                            <div class="layui-form hxradmin-card-header">
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label" style="width: 140px;">时间范围</label>
                                        <div class="layui-input-inline" style="width: 250px;">
                                            <input type="text" name="search_time_agent" id='date-2' class="layui-input" readonly>
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">类型</label>
                                        <div class="layui-input-inline">
                                            <div class="layui-unselect layui-form-select">
                                                <div class="layui-select-title"><input name="type" type="text" placeholder="充值" value="" readonly class="layui-input layui-unselect"><i
                                                        class="layui-edge"></i></div>
                                                <dl class="layui-anim layui-anim-upbit" style="">
                                                    <dd data='1' class="layui-this">充值</dd>
                                                    <dd data='2'>消费</dd>
                                                    <dd data='3'>分红</dd>
                                                    <dd data='4'>收益</dd>
                                                </dl>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <button class="layui-btn agentsearch" data-type="reload" >搜索</button>
                                    </div>
                                    <div class="layui-inline">
                                        <button class="layui-btn pexcel" data-type="excel" id="pexcel">导出数据</button>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-card-body">
                                <table class="layui-hide" id="member-list-table" lay-filter="agent-list-table"></table>
                            </div>
                        </div>
                        <div class="layui-tab-item" id="damagesset">
                            <div class="layui-form hxradmin-card-header">
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label" style="width: 140px;">时间范围</label>
                                        <div class="layui-input-inline" style="width: 250px;">
                                            <input type="text" name="search_time_agent" id='date-3' class="layui-input" readonly>
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">类型</label>
                                        <div class="layui-input-inline">
                                            <div class="layui-unselect layui-form-select">
                                                <div class="layui-select-title"><input name="type" type="text" placeholder="充值" value="" readonly class="layui-input layui-unselect"><i
                                                        class="layui-edge"></i></div>
                                                <dl class="layui-anim layui-anim-upbit" style="">
                                                    <dd data='1' class="layui-this">充值</dd>
                                                    <dd data='2'>消费</dd>
                                                    <dd data='3'>收益</dd>
                                                    <dd data='4'>效益</dd>
                                                </dl>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <button class="layui-btn agentsearch" data-type="reload" >搜索</button>
                                    </div>
                                    <div class="layui-inline">
                                        <button class="layui-btn pexcel" data-type="excel" id="pexcel">导出数据</button>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-card-body">
                                <table class="layui-hide" id="school-list-table" lay-filter="agent-list-table"></table>
                            </div>
                        </div>
                        <div class="layui-tab-item" id="drawingsset">
                            <div class="layui-form hxradmin-card-header">
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label" style="width: 140px;">时间范围</label>
                                        <div class="layui-input-inline" style="width: 250px;">
                                            <input type="text" name="search_time_agent" id='date-4' class="layui-input" readonly>
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">类型</label>
                                        <div class="layui-input-inline">
                                            <div class="layui-unselect layui-form-select">
                                                <div class="layui-select-title"><input name="type" type="text" placeholder="充值" value="" readonly class="layui-input layui-unselect"><i
                                                        class="layui-edge"></i></div>
                                                <dl class="layui-anim layui-anim-upbit" style="">
                                                    <dd data='1' class="layui-this">充值</dd>
                                                    <dd data='2'>消费</dd>
                                                    <dd data='3'>收益</dd>
                                                </dl>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <button class="layui-btn agentsearch" data-type="reload" id="agentsearch">搜索</button>
                                    </div>
                                    <div class="layui-inline">
                                        <button class="layui-btn pexcel" data-type="excel" id="pexcel">导出数据</button>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-card-body">
                                <table class="layui-hide" id="dormitory-list-table" lay-filter="agent-list-table"></table>
                            </div>
                        </div>

                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
</div>
<script type="text/html" id="status">
    {{#  if(d.status == 1){ }}
    <span class="layui-badge">启动</span>
    {{#  } else if(d.status == 2) { }}
    <span class="layui-badge layui-bg-green">锁定</span>
    {{#  } }}
</script>
<style type="text/css">
    #drawingsset .layui-form-label{
        width: 150px;
    }

    #break_set .layui-form-label{
        width: 150px;
    }
    #commission .layui-form-label{
        width: 150px;
    }
    #benefit .layui-form-label{
        width: 150px;
    }
    #drawset .layui-form-label{
        width: 150px;
    }
    #recharge .layui-form-label{
        width: 150px;
    }
    #rechargeset .layui-btn-danger{
        display: inline-block !important;
    }

</style>
<script>
    layui.use(['table', 'form','laydate','element'], function(form,element) {
        var table = layui.table,
            form = layui.form,
            $ = layui.$,laydate=layui.laydate
            ,element = layui.element;
        //日期范围
        laydate.render({
            elem: '#date-1'
            ,range: true
        });
        //日期范围
        laydate.render({
            elem: '#date-2'
            ,range: true
        });
        //日期范围
        laydate.render({
            elem: '#date-3'
            ,range: true
        });
        //日期范围
        laydate.render({
            elem: '#date-4'
            ,range: true
        });
        var  elen='agent-list-table',url='ranking/agent_statistics',
            fields=[
            [{
                field: 'no',
                title: '排名',
                width: 60,
                align:'center'
            }, {
                field: 'agent_name',
                title: '登录名',
                width: 150
            }, {
                field: 'real_name',
                title: '真实姓名',
                width: 120,
                align:'center'
            },{
                field: 'school_name',
                title: '负责学校',
                width: 150,
                align:'center'
            }, {
                field: 'recharge_money',
                title: '充值金额',
                minWidth: 80
            }, {
                field: 'consume_money',
                title: '消费金额',
                minWidth: 60
            },{
                field: 'income_money',
                title: '收益金额',
                minWidth: 80
            },{
                field: 'benefit_money',
                title: '效益值',
                minWidth: 80
            },{
                field:'blance_money',
                title:'佣金',
                minWidth: 80
            }]
        ];
        layui.admin.initlist(table,url,240,fields,'#'+elen);

        element.on('tab()', function() {
            var item_val = $(this).attr('value');
            if (item_val == 1) {//代理会员
                elen='agent-list-table',url='ranking/agent_statistics',
                    fields=[
                        [{
                            field: 'no',
                            title: '排名',
                            width: 60
                        }, {
                            field: 'agent_name',
                            title: '登录名',
                            width: 150
                        }, {
                            field: 'real_name',
                            title: '真实姓名',
                            width: 120
                        },{
                            field: 'school_name',
                            title: '负责学校',
                            width: 150
                        }, {
                            field: 'recharge_money',
                            title: '充值金额',
                            minWidth: 100
                        }, {
                            field: 'consume_money',
                            title: '消费金额',
                            minWidth: 100
                        },{
                            field: 'income_money',
                            title: '收益金额',
                            minWidth: 100
                        },{
                            field: 'benefit_money',
                            title: '效益值',
                            minWidth: 100
                        },{
                            field:'blance_money',
                            title:'佣金',
                            minWidth: 100
                        }]
                    ];
            }else if (item_val==2){//会员
                 elen='member-list-table',url='ranking/member_statistics',fields=[
                    [{
                        field: 'no',
                        title: '排名',
                        width: 60
                    },{
                        field: 'real_name',
                        title: '真实姓名',
                        width: 60
                    },{
                        field: 'school_name',
                        title: '所在学校',
                        width: 200
                    }, {
                        field: 'recharge_money',
                        title: '充值金额',
                        minWidth: 100
                    }, {
                        field: 'consume_money',
                        title: '消费金额',
                        minWidth: 100
                    },{
                        field: 'income_money',
                        title: '收益金额',
                        minWidth: 100
                    },{
                        field:'blance_money',
                        title:'分红',
                        minWidth: 100
                    }]
                ];
            }else if (item_val==3){//学校
                 elen='school-list-table',url='ranking/school_statistics',fields=[
                    [{
                        field: 'no',
                        title: '排名',
                        width: 60
                    }, {
                        field: 'school_name',
                        title: '学校',
                        width: 250
                    }, {
                        field: 'recharge_money',
                        title: '充值金额',
                        minWidth: 150
                    }, {
                        field: 'consume_money',
                        title: '消费金额',
                        minWidth: 150
                    },{
                        field: 'income_money',
                        title: '收益金额',
                        minWidth: 150
                    },{
                        field: 'benefit_money',
                        title: '效益值',
                        minWidth: 150
                    }]
                ];
            }else if (item_val==4){//宿舍
                 elen='dormitory-list-table',url='ranking/dormitory_statistics',fields=[
                    [{
                        field: 'no',
                        title: '排名',
                        width: 60
                    },{
                        field: 'school_name',
                        title: '学校',
                        width: 200
                    }, {
                        field: 'dormitory',
                        title: '宿舍',
                        width: 200
                    },  {
                        field: 'recharge_money',
                        title: '充值金额',
                        minWidth: 100
                    }, {
                        field: 'consume_money',
                        title: '消费金额',
                        minWidth: 100
                    },{
                        field: 'income_money',
                        title: '收益金额',
                        minWidth: 100
                    }]
                ];
            }

            if ($(this).attr('click_num') != 1) return false;
            $(this).attr('click_num', 2);
            layui.admin.initlist(table,url,240,fields,'#'+elen);
        });
        $('.agentsearch').on('click', function() {
            var obj=$(this).parents('.layui-form-item');
            var search_time = obj.find('input[name="search_time_agent"]').val();
            var val3 = obj.find('input[name="type"]').attr('data');
      
            layui.admin.reloads({
                datemin:search_time.split(' ')[0],
                datemax:search_time.split(' ')[2],
                type:val3
            },elen)
        });
        //导出
        $('.pexcel').on('click', function() {
            var obj=$(this).parents('.layui-form-item');
            var search_time = obj.find('input[name="search_time_agent"]').val();
            var val3 = obj.find('input[name="type"]').attr('data');
            layui.admin.excel(table,url,
                {
                    datemin:search_time.split(' ')[0],
                    datemax:search_time.split(' ')[2],
                    type:val3
                },'',elen);
        });
    })
</script>